package com.example.demo.config;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class LoginInteracept implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Object msg1 = request.getSession().getAttribute("msg1");
        if(msg1==null){
             request.setAttribute("msg","请先登录!!!");
             request.getRequestDispatcher("/").forward(request,response);
            return false;
        }else{
                  return true;
        }

    }
}
